import { Navigate, RouterProvider, createBrowserRouter } from 'react-router-dom';
import { ErrorRoutes } from '@/router/routes/error-routes';
import { AuthRoutes } from '@/router/routes/auth-routes';

import WithRouter from './withRouter';

const LoginRoute = [];
const PAGE_NOT_FOUND_ROUTE = {
  path: '*',
  element: <Navigate to="/404" replace />,
};

export default function Router() {
  const routes = [{
    element: <WithRouter />,
    children: [...LoginRoute, AuthRoutes, ErrorRoutes, PAGE_NOT_FOUND_ROUTE]
  }];
  const router = createBrowserRouter(routes);

  return <RouterProvider router={router} />;
}
